package iedcyt.acute.dataAccess.dao.maescorp;


import iedcyt.acute.dataAccess.domain.maescorp.Maescorp;
import iedcyt.acute.dataAccess.generic.SpringDao;
import iedcyt.acute.dataAccess.idao.maescorp.IMaescorpWoSDao;

import java.util.List;



public class MaescorpWoSDao extends SpringDao implements IMaescorpWoSDao  {

	
	@Override
	public List<Maescorp> selectAll() {
		
		return _jdbcTemplate.query("SELECT * FROM Maescorp",
				new MaescorpWoSRowMapper());
	}
	
	
	

	@Override
	public void insert(Maescorp doc) {
	
		_jdbcTemplate.update("INSERT INTO Maescorp (CORP,PROVINCIA,INSTIT,ORGANISMO,DPTO,[FECHA CODIFICACION]) VALUES (?,?,?,?,?,?)",
				new Object[] { doc.get_CORP(), doc.get_PROVINCIA(), doc.get_INSTIT(), doc.get_ORGANISMO(), doc.get_DPTO(), 
		doc.get_FECHA_CODIFICACION() });
		
	}
	
	@Override
	public void delete(String corp) {
	
		_jdbcTemplate.update("DELETE from Maescorp WHERE CORP LIKE ?",
				new Object[] { corp  });
		
	}
	

	@Override
	public List<Maescorp> selectByPIOD(String prov, String instit, String org, String dpto) {
		return _jdbcTemplate
		.query(
				"SELECT * FROM Maescorp WHERE PROVINCIA LIKE ? AND INSTIT LIKE ? AND ORGANISMO LIKE ? AND DPTO LIKE ?",
				new Object[] { prov,  instit,  org,  dpto  },
				new MaescorpWoSRowMapper());
	}

	@Override
	public List<Maescorp> selectByPROVINCIA(String prov) {
		return _jdbcTemplate
		.query(
				"SELECT * FROM Maescorp WHERE PROVINCIA LIKE ?",
				new Object[] { prov },
				new MaescorpWoSRowMapper());
	}




	@Override
	public List<Maescorp> selectByPROVINCIAByInitial(String prov, String initial) {
		return _jdbcTemplate
		.query(
				"SELECT * FROM Maescorp WHERE PROVINCIA LIKE ? AND CORP LIKE ?",
				new Object[] { prov, initial + "%" },
				new MaescorpWoSRowMapper());
	}




	

	
	
}

